<?php
    /**
     * 打印数据
     *
     */
    function dd() {
        array_map(function($x) { echo "<pre>";print_r($x); }, func_get_args());
        exit;
    }

    /**
     
     * 返回上传文件的名称
     * @return [type] [description]
     
     */
    function my_uniqid(){
        return date('His').uniqid().rand(100000,999999);
    }
    /**
     
     * @param  encryptionType:0; //加密方式  0-明文  2-aes
     * @param  data:{}; //返回参数
     * @param  resultCode:0; //错误码
     * @param  key //加密key
     * @return msg:请求成功；//请求成功失败提示
     
     */
    function return_json($code=array(),$data=array()){
	    header('Access-Control-Allow-Origin:*');
	    header('Access-Control-Allow-Headers:accept, cache-control, content-type, x-requested-with');
	    header('Access-Control-Max-Age:3628800');
        
        echo  json_encode(
                array(
                    'data'           =>$data,
                    'resultCode'     =>$code['code'],
                    'msg'            =>$code['msg'],
                )
            );
        exit;
    } 
    /**
     * 日志
     * @param  [type] $data [description]
     * @return [type]       [description]
     */
    function log_file($data){
        file_put_contents('./log.log', "<?php\nreturn " . var_export($data, true) . ';');
    }
    //判断是否是https请求
    function is_HTTPS(){  
        if($_SERVER['HTTPS'] === 1){  //Apache  
            return TRUE;  
        }elseif($_SERVER['HTTPS'] === 'on'){ //IIS  
            return TRUE;  
        }elseif($_SERVER['SERVER_PORT'] == 443){ //其他  
            return TRUE;  
        }  
        return FALSE;  
    }  
?>